function Weather_UDP_Server_Tx(block)
%*=+--+=#=+--      UAS Severe Weather Simulation Softeware        --+=#=+--+=#*%
%          Copyright (C) 2013 Regents of the University of Colorado.           %
%                             All Rights Reserved.                             %
%                                                                              %
%    This program is free software: you can redistribute it and/or modify      %
%    it under the terms of the GNU General Public License version 2 as         %
%    published by the Free Software Foundation.                                %
%                                                                              %
%    This program is distributed in the hope that it will be useful,           %
%    but WITHOUT ANY WARRANTY; without even the implied warranty of            %
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             %
%    GNU General Public License for more details.                              %
%                                                                              %
%    You should have received a copy of the GNU General Public License         %
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.     %
%                                                                              %
%           Jack Elston                                                        %
%           elstonj@colorado.edu                                               %
%                                                                              %
%*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*%
	setup(block);

function setup(block)
	block.NumDialogPrms = 2;

	block.NumInputPorts = 3;
	block.NumOutputPorts = 0;

	block.SetPreCompInpPortInfoToDynamic;
  block.SetPreCompOutPortInfoToDynamic;

  block.InputPort(1).Complexity   = 'Real';
  block.InputPort(1).DataTypeId   = 0;
  block.InputPort(1).SamplingMode = 'Sample';
  block.InputPort(1).Dimensions   = 1;

  block.InputPort(2).Complexity   = 'Real';
  block.InputPort(2).DataTypeId   = 6;
  block.InputPort(2).SamplingMode = 'Sample';
  block.InputPort(2).Dimensions   = 3;

  block.InputPort(3).Complexity   = 'Real';
  block.InputPort(3).DataTypeId   = 3;
  block.InputPort(3).SamplingMode = 'Sample';
  block.InputPort(3).Dimensions   = 1;

	block.SampleTimes = [-1 0]; % how do I get varables from the workspace?

	block.RegBlockMethod('PostPropagationSetup',    @DoPostPropSetup);
	block.RegBlockMethod('Start',                   @Start);  
	block.RegBlockMethod('Outputs',                 @Outputs);
	block.RegBlockMethod('Terminate',               @Terminate);

function DoPostPropSetup(block)

function Start(block)

function Outputs(block)
	udp = block.InputPort(1).Data;

	config_type  = 0;
	wind_type    = 1;

	host = block.DialogPrm(1).data;
	port = block.DialogPrm(2).data;

	wind = block.InputPort(2).Data;
	stop = block.InputPort(3).Data;

	windData = [uint8(wind_type);
						 flipud(typecast(wind(1),'uint8')');
						 flipud(typecast(wind(2),'uint8')');
						 flipud(typecast(wind(3),'uint8')')
	];

	configData = [uint8(config_type); uint8(stop)];

	if stop == 1
		if udp~=-1,
			try,
				pnet(udp,'write',configData);                  % Write to write buffer
				pnet(udp,'writepacket',host,port,'noblock');   % Send buffer as UDP packet
			end
		else
			fprintf(1,'Socket not connected\n');
		end
	else
		if udp~=-1,
			try,
				pnet(udp,'write',windData);                    % Write to write buffer
				pnet(udp,'writepacket',host,port,'noblock');   % Send buffer as UDP packet
			end
		else
			fprintf(1,'Socket not connected\n');
		end
	end

function Terminate(block)
